
from fastapi import APIRouter, Depends

from src.servers.task_server import TaskServer
from src.models import ResponseModel
from src.models.request import WaybillParams
from src.routers import verify_token

router = APIRouter(dependencies=[Depends(verify_token)])

def get_server():
    return TaskServer()

@router.post("/create_task",response_model=ResponseModel)
async def create_task(request:WaybillParams,service:TaskServer = Depends(get_server)):
    return service.create(request)


@router.get("/run_task",response_model=ResponseModel)
async def run_task(task_id:str,service:TaskServer = Depends(get_server)):
    return service.run(task_id)

@router.get("/delete_task", response_model=ResponseModel)
async def delete_task(task_id: str,service:TaskServer = Depends(get_server)):
    return service.delete(task_id)


@router.get("/get_task_result", response_model=ResponseModel)
async def get_task_result(task_id: str,service:TaskServer = Depends(get_server)):
    return service.get_result(task_id)



